<?php

$url='.';
$openid='1';

$endTime=strtotime("2020-09-23 20:15:00");
$startTime=strtotime(date("Y-m-j H:i:s"));
$cha=$endTime - $startTime;
$m = floor(($cha%(3600*24))%3600/60);
$s = floor(($cha%(3600*24))%60);


$aTiShu=40;
$nianji=6;
$randId=rand(1,2);

$path='./tiKu/'.$nianji.'-1-'.$randId.'.txt';
$tiData=json_decode(file_get_contents($path), true);
$tiAInfo=$tiData['a'];
$tiA=array();
$tiId=array();
foreach ($tiAInfo as $k => $v){
    $tiA[]=array('title'=>$v['title']);
    $tiId[]=$v['id'];
}
$tiId[]=239;
$tiId[]=240;

$path='./tiKu/'.$nianji.'-2-'.$randId.'.txt';
$tiData=json_decode(file_get_contents($path), true);
$tiBInfo=$tiData['a'];
$tiB=array();
foreach ($tiBInfo as $k => $v){
    $tiB[]=array('title'=>$v['title'],'da'=>$v['da'],'db'=>$v['db'],
        'dc'=>$v['dc'],'dd'=>$v['dd']
    );
    $tiId[]=$v['id'];
}

$path='./tiKu/'.$nianji.'-3-'.$randId.'.txt';
$tiData=json_decode(file_get_contents($path), true);
$tiCInfo=$tiData['a'];
$tiC=array();
foreach ($tiCInfo as $k => $v){
    $tiC[]=array('title'=>$v['title'],'da'=>$v['da'],'db'=>$v['db'],
        'dc'=>$v['dc'],'dd'=>$v['dd']
    );
    $tiId[]=$v['id'];
}
$tiAInfo=$tiBInfo=$tiCInfo=NULL;
?><!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1">
<title>中学生古诗文大会</title>
<style>
html,body{font-size:16px;background:#f5f3e9;width:100%;font-size:12px;color:#fff;font-family:Microsoft YaHei, Gotham, "Helvetica Neue", Helvetica, Arial, sans-serif;}
body, div{position:relative;padding:0px;margin:0px auto;max-width:750px;}
.weui-dialog{position:fixed;z-index:5000;width:80%;max-width:300px;top:50%;left:50%;-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);background-color:#FFF;text-align:center;border-radius:3px;overflow:hidden}.weui-dialog__hd{padding:1.3em 1.6em .5em}.weui-dialog__title{font-weight:400;font-size:18px}.weui-dialog__bd{padding:0 1.6em .8em;min-height:40px;font-size:15px;line-height:1.3;word-wrap:break-word;word-break:break-all;color:#999}.weui-dialog__bd:first-child{padding:1.2em 20px .1em;color:#353535}.weui-dialog__ft{position:relative;line-height:48px;font-size:18px;display:-webkit-box;display:-webkit-flex;display:flex}.weui-dialog__ft:after{content:" ";position:absolute;left:0;top:0;right:0;height:1px;border-top:1px solid #D5D5D6;color:#D5D5D6;-webkit-transform-origin:0 0;transform-origin:0 0;-webkit-transform:scaleY(.5);transform:scaleY(.5)}.weui-dialog__btn{display:block;-webkit-box-flex:1;-webkit-flex:1;flex:1;color:#3CC51F;text-decoration:none;-webkit-tap-highlight-color:transparent;position:relative}.weui-dialog__btn:active{background-color:#EEE}.weui-dialog__btn:after{content:" ";position:absolute;left:0;top:0;width:1px;bottom:0;border-left:1px solid #D5D5D6;color:#D5D5D6;-webkit-transform-origin:0 0;transform-origin:0 0;-webkit-transform:scaleX(.5);transform:scaleX(.5)}.weui-dialog__btn:first-child:after{display:none}.weui-dialog__btn_default{color:#353535}.weui-dialog__btn_primary{color:#0BB20C}@media screen and (min-width:1024px){.weui-dialog{width:35%}}.weui-mask{position:fixed;z-index:1000;top:0;right:0;left:0;bottom:0;background:rgba(0,0,0,.6)}.weui-mask_transparent{position:fixed;z-index:1000;top:0;right:0;left:0;bottom:0}
-webkit-touch-callout:none;
-webkit-user-select:none;
html{-ms-touch-action:none;}
div,img{-webkit-tap-highlight-color:rgba(0,0,0,0);}
*{-webkit-text-size-adjust: none;}
.simg{position:absolute;display:block;}
a{text-decoration:none;}
.txt{position:absolute;text-indent:6px;font-size:12px;z-index:2;}
.txt::-webkit-input-placeholder {color:#b4b4b4;text-align:left;}
.container{position:relative;width:100%;height:auto;}
.hide{display:none;}
.p-b, .page{position:absolute;width:100%;height:100%;top:0;left:0;}
.ti-top{position:relative;width:100%;margin:0;padding:0;}
.ti-tu, .dan-t1{position:absolute;width:100%;display:block;top:0;left:0;}
.ti-time, .ti-title{position:absolute;width:100%;text-align:center;color:#000;}
.ti-time{font-size:12px;font-weight:700;}
.ti-title{font-size:20px;font-weight:700;}
.ti-wen{width:80%;margin-left:10%;color:#666666;font-size:16px;height:auto;}
.ti-wen p{padding:0px 0px 5px 0px;}
.ti-pan, .ti-dan, .ti-duo{position:relative;width:100%;padding-top:5px;}
.ti-pan-gap, .ti-pan-gap-two, .ti-dan-gap{position:relative;width:100%;}
.ti-pan-gap{height:10px;}
.pan-yes, .pan-no{width:100%;}
.pan-yes-tu, .pan-no-tu{position:absolute;left:0;}
.ti-sxt{width:100%;}
.dan-ti{width:80%;margin-left:10%;color:#333333;font-size:12px;height:auto;}
.dan-t2, .duo-t2{padding:6px 0px 10px 0px;border-bottom:1px solid #afaba8;line-height:16px;font-weight:600;}
.clear{clear:both;}
.t-bg{position:absolute;width:100%;height:100%;background-color:#000;opacity:.86;z-index:9;top:0px;left:0px;display:none;}
.tip-wan, .t-time{position:absolute;width:100%;height:100%;z-index:9999;top:0px;left:0px;display:none;}
.ti-wen-tu{width:100%;height:auto;}
.ti-wen-t1{position:absolute;width:100%;left:-2%;}
.dan-t2 span{border-bottom:1px solid #000;padding-bottom:4px}
</style>
</head>
<body>
<div class="container">
  <div class="page">
    <img class="p-b" src="<?php echo $url; ?>/img/ti.jpg">
    <div class="ti-top">
      	<img class="ti-p1 simg" src="<?php echo $url; ?>/img/ti-p1.png">
      	<img class="ti-p2 simg" src="<?php echo $url; ?>/img/ti-p2.png">	
      	<img class="ti-tu" src="<?php echo $url; ?>/img/ti-top.png">
      	<div class="ti-time"><?php
  		$fen=$m;
  		if ($m < 0){$m=0;}
  		if ($m < 10){$fen='0'.$m;}
  		if ($s < 0){$s=0;}
  		$miao=$s;
  		if ($s < 10){$miao='0'.$s;}
  		echo $fen,':',$miao; ?></div>
  		<div class="ti-title">第一题 （1/<?php echo $aTiShu ?>）</div>
     </div> 
  	 <div class="ti-wen"><p><?php echo $tiA[0]['title']; ?>wèi yí</p></div>
  	 <div class="ti-wen-tu hide">
  	 	<img class="ti-wen-t1" src="<?php echo $url; ?>/img/pan-tm1.png">
  	 </div>
  	 
  	 <div class="ti-pan">
  	     <div class="ti-pan-gap"></div>
  	     <div class="pan-yes">
  	       <img class="pan-yes-tu" src="<?php echo $url; ?>/img/ti-yes.png">
  	     </div>
  	     <div class="pan-no">
  	       <img class="pan-no-tu" src="<?php echo $url; ?>/img/ti-no.png">
  	     </div>
  	     <div class="ti-pan-gap-two"></div>  
  	 </div>
  	 <div class="ti-dan hide">
  	    <div class="dan-a dan-ti">
  	      <img class="dan-c simg" src="<?php echo $url; ?>/img/dan-no.png">
  	      <div class="dan-t2">弄儿床前戏，看妇机中织</div>
  	      <div class="clear"></div>
  	    </div>
  	    <div class="dan-b dan-ti">
  	      <img class="dan-c simg" src="<?php echo $url; ?>/img/dan-no.png">
  	      <div class="dan-t2">弃置罢官去，还家自休息</div>
  	      <div class="clear"></div>
  	    </div>
  	    <div class="dan-c dan-ti">
  	      <img class="dan-c simg" src="<?php echo $url; ?>/img/dan-no.png">
  	      <div class="dan-t2">朝出与亲辞，暮还在亲侧</div>
  	      <div class="clear"></div>
  	    </div>
  	    <div class="dan-d dan-ti">
  	      <img class="dan-c simg" src="<?php echo $url; ?>/img/dan-no.png">
  	      <div class="dan-t2">自古圣贤皆贫贱，何况我辈孤且直</div>
  	      <div class="clear"></div>
  	    </div>
  	    <div class="ti-dan-gap"></div> 
  	 </div>
  	 
  	 <div class="ti-duo hide">
  	    <div class="duo-a1 dan-ti">
  	      <img class="duo-c simg" src="<?php echo $url; ?>/img/duo-no.png">
  	      <div class="duo-t2">弄儿床前戏，看妇机中织</div>
  	      <div class="clear"></div>
  	    </div>
  	    <div class="duo-b1 dan-ti">
  	      <img class="duo-c simg" src="<?php echo $url; ?>/img/duo-no.png">
  	      <div class="duo-t2">弄儿床前戏，看妇机中织</div>
  	      <div class="clear"></div>
  	    </div>
  	    <div class="duo-c1 dan-ti">
  	      <img class="duo-c simg" src="<?php echo $url; ?>/img/duo-no.png">
  	      <div class="duo-t2">弄儿床前戏，看妇机中织</div>
  	      <div class="clear"></div>
  	    </div>
  	    <div class="duo-d1 dan-ti">
  	      <img class="duo-c simg" src="<?php echo $url; ?>/img/duo-no.png">
  	      <div class="duo-t2">弄儿床前戏，看妇机中织</div>
  	      <div class="clear"></div>
  	    </div>
  	    
  	 
  	 </div>

  	 <div class="ti-sxt">
		<img class="ti-pre simg" src="<?php echo $url; ?>/img/ti-pre.png">
  		<img class="ti-next simg" src="<?php echo $url; ?>/img/ti-next.png">
  		<img class="ti-jiao hide simg" src="<?php echo $url; ?>/img/ti-jiao.png">
	 </div>	
  	 
  		
  </div>
  
  <div class="t-bg"></div>
  <div class="dan page hide">
     <img class="p-b" src="<?php echo $url; ?>/img/p2.jpg">
     <img class="dan-t1 simg " src="<?php echo $url; ?>/img/dan-t1.png">
     <div class="dan-ok simg"></div>
  </div>
  <div class="duo page hide">
     <img class="p-b" src="<?php echo $url; ?>/img/p2.jpg">
     <img class="dan-t1 simg " src="<?php echo $url; ?>/img/duo-t1.png">
     <div class="duo-ok simg"></div>
  </div> 
  <div class="tip-wan">
	<img class="twan-t1 simg" src="<?php echo $url; ?>/img/tip-wan.png">
  </div>


</div>
<script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<script>
h= Math.max(document.documentElement.clientHeight, window.innerHeight || 0);
var sWidth = parseInt((window.innerWidth > 0) ? window.innerWidth : screen.width);
if(sWidth>750){sWidth=750;}
var _rate=(sWidth/750);
var _tiA=<?php echo json_encode($tiA); ?>;
var _tiB=<?php echo json_encode($tiB); ?>;
var _tiC=<?php echo json_encode($tiC); ?>;
var _curStep=1;
var _tiIndex=0;
var _uD1=[];
for(i=0;i<41;i++){
	_uD1[i]='';
}
var _uD2=[];
for(i=0;i<121;i++){
	_uD2[i]='';
}
var _uD3=[];
for(i=0;i<41;i++){
	_uD3[i]='';
}
var _duoAbcd={a:'',b:'',c:'',d:''};
var _fdes='<?php echo $openid; ?>';
$(function(){
	$('.container, .page').width(sWidth).height(h);
	$(".ti-top").height(_rate*170);
	$('.ti-p1, .ti-p2').width(_rate*592).height(_rate*43).css({"top":_rate*78,"left":_rate*79});
	$(".ti-time").css({"top":_rate*52 });
	$(".ti-title").css({"top":_rate*126});
	$(".ti-wen").css({"min-height":_rate*180});
	$(".ti-wen-tu").height(_rate*180);
	$('.ti-wen-t1').css({"top":_rate*30});
	$(".pan-yes, .pan-no").height(_rate*100);
	$('.pan-yes-tu, .pan-no-tu').width(_rate*294).css({"top":_rate*10});
	$('.pan-yes-tu').height(_rate*51);
	$('.pan-no-tu').height(_rate*48);
	$('.ti-pan-gap-two').height(_rate*250);
	$('.ti-pre, .ti-next, .ti-jiao').width(_rate*288).height(_rate*102);
	$('.ti-pre').css({"top":0, "left":_rate*80});
	$('.ti-next, .ti-jiao').css({"top":0, "right":_rate*80});
	$(".dan-ok, .duo-ok").width(_rate*490).height(_rate*130).css({"top":_rate*760, "left":_rate*130});
	$(".dan-c").width(_rate*44).height(_rate*44).css({"top":_rate*6, "left":0});
	$(".dan-t2, .duo-t2").width(_rate*500).css({"margin-left":_rate*70,'padding-top':_rate*10,'padding-bottom':_rate*20});
	$(".dan-ti").css({'min-height':_rate*100,"margin-top":_rate*20});
	$('.ti-dan-gap').height(_rate*120);
	$(".duo-c").width(_rate*56).height(_rate*52).css({"top":0, "left":0});
	 
	
	var _tmpTop=h - _rate*500;
	$(".twan-t1").width(sWidth).height(_rate*465).css({"top":_tmpTop/2, "left":0});


	function _step1(){
		var _zwen=chinanum(_tiIndex+1);  
 		$(".ti-title").html("第"+_zwen+"题（"+(_tiIndex+1)+"/40）");
 		if(38 == _tiIndex){
 		   $(".ti-wen-t1").attr("src","<?php echo $url; ?>/img/pan-tm1.png"); 	 		
 		   $(".ti-wen").hide();
           $(".ti-wen-tu").show();
        }
 		if(39 == _tiIndex){
  		   $(".ti-wen-t1").attr("src","<?php echo $url; ?>/img/pan-tm2.png"); 	 		
            $(".ti-wen").hide();
            $(".ti-wen-tu").show();
         }

 		if(38 >  _tiIndex){
 		  $(".ti-wen p").html(_tiA[_tiIndex].title); 
 		  $(".ti-wen").show();
          $(".ti-wen-tu").hide();	
 		}
     	
		$(".pan-yes-tu").attr("src","<?php echo $url; ?>/img/ti-yes.png");
		$(".pan-no-tu").attr("src","<?php echo $url; ?>/img/ti-no.png");
    	if(_uD1[_tiIndex] != ''){
          	if('a' == _uD1[_tiIndex]){
          		$(".pan-yes-tu").attr("src","<?php echo $url; ?>/img/ti-yes2.png");
            }else{
            	$(".pan-no-tu").attr("src","<?php echo $url; ?>/img/ti-no2.png");
            }
        }
	}
	function _step2(){
		var _zwen=chinanum(_tiIndex+1);  
 		$(".ti-title").html("第"+_zwen+"题（"+(_tiIndex+1)+"/108）");
     	$(".ti-wen p").html(_tiB[_tiIndex].title);
     	
     	//$(".dan-a .dan-t2").html("人<span>生</span>几何?");
     	$(".dan-a .dan-t2").html(_tiB[_tiIndex].da);
		$(".dan-b .dan-t2").html(_tiB[_tiIndex].db);
		$(".dan-c .dan-t2").html(_tiB[_tiIndex].dc);
		$(".dan-d .dan-t2").html(_tiB[_tiIndex].dd);
		
		$(".dan-c").attr("src","<?php echo $url; ?>/img/dan-no.png");
		if(_uD2[_tiIndex] != ''){
			$(".dan-"+_uD2[_tiIndex]+" .dan-c").attr("src","<?php echo $url; ?>/img/dan-yes.png");
        }
	}
	function _step3(){
		$(".duo-c").attr("src","<?php echo $url; ?>/img/duo-no.png");
		_duoAbcd={a:'',b:'',c:'',d:''};
		var _zwen=chinanum(_tiIndex+1);  
 		$(".ti-title").html("第"+_zwen+"题（"+(_tiIndex+1)+"/36）");
     	$(".ti-wen p").html(_tiC[_tiIndex].title);
     	$(".duo-a1 .dan-t2").html(_tiC[_tiIndex].da);
		$(".duo-b1 .dan-t2").html(_tiC[_tiIndex].db);
		$(".duo-c1 .dan-t2").html(_tiC[_tiIndex].dc);
		$(".duo-d1 .dan-t2").html(_tiC[_tiIndex].dd);
		if(_uD3[_tiIndex] != ''){
			var _tmpArr=_uD3[_tiIndex].split(",");
			for(var i=0;i<_tmpArr.length;i++){
				_duoAbcd[_tmpArr[i]]=1;
				$(".duo-"+_tmpArr[i]+"1 .duo-c").attr("src","<?php echo $url; ?>/img/duo-yes.png");
			} 
        }
	}
	$(".ti-pre").click(function(){
		if(_tiIndex < 1){return;}
		$(".ti-jiao").hide();
		$(".ti-next").show();
        _tiIndex--;
        if(1 == _curStep){
        	_step1();
        }
        if(2 == _curStep){
        	_step2();
        }
        if(3 == _curStep){
        	_step3();
        }
        
        
	});

	
	$(".ti-next").click(function(){
        _tiIndex++;
        
        if(40 == _tiIndex && 1 == _curStep){
            $(".dan").show();
            _curStep=2;
            _tiIndex=0;
            return;
         }
        if(109 == _tiIndex && 2 == _curStep){
            $(".duo").show();
            _curStep=3;
            _tiIndex=0;
            return;
        }
        if(36 == _tiIndex && 3 == _curStep){
        	var _d1=JSON.stringify(_uD1);
        	var _d2=JSON.stringify(_uD2);
        	var _d3=JSON.stringify(_uD3);
		    $.post("api/?c=cishu", {fdes:_fdes,d1:_d1,d2:_d2,d3:_d3,tid:'<?php echo json_encode($tiId); ?>'}, function(data){
		    	    $(".ti-next").hide();
	        		$(".ti-jiao").show();
			      }, "json"); 
            return;
         }
        if(1 == _curStep){
         	_step1();
        }
        if(2 == _curStep){
        	_step2();
        }
        if(3 == _curStep){
        	_step3();
        }
	});

	
	$(".ti-jiao").click(function(){
	   $(".t-bg, .tip-wan").fadeIn();
	});
	
	$(".dan-ok").click(function(){
		$(".ti-pan").hide();
		$(".ti-dan").show();
		$(".dan").hide();
		_curStep=2;
        _tiIndex=0;
        _step2();
        _tiIndex=105;//test
	});
	_tiIndex=36;//test
	$(".duo-ok").click(function(){
		$(".ti-dan").hide();
		$(".ti-duo").show();
		$(".duo").hide();
		_curStep=3;
        _tiIndex=0;
        _step3();
        _tiIndex=34;//test
	});

	$(".pan-yes").click(function(){
		$(".pan-no-tu").attr("src","<?php echo $url; ?>/img/ti-no.png");
		$(".pan-yes-tu").attr("src","<?php echo $url; ?>/img/ti-yes2.png");
		_uD1[_tiIndex]='a';
	});
	$(".pan-no").click(function(){
		$(".pan-yes-tu").attr("src","<?php echo $url; ?>/img/ti-yes.png");
		$(".pan-no-tu").attr("src","<?php echo $url; ?>/img/ti-no2.png");
		_uD1[_tiIndex]='b';
	});

	function _clickDan(_type){
		$(".dan-c").attr("src","<?php echo $url; ?>/img/dan-no.png");
		$(".dan-"+_type+" .dan-c").attr("src","<?php echo $url; ?>/img/dan-yes.png");
	}
	$(".dan-a").click(function(){
		_uD2[_tiIndex]='a';
		_clickDan('a');
	});
	$(".dan-b").click(function(){
		_uD2[_tiIndex]='b';
		_clickDan('b');
	});
	$(".dan-c").click(function(){
		_uD2[_tiIndex]='c';
		_clickDan('c');
	});
	$(".dan-d").click(function(){
		_uD2[_tiIndex]='d';
		_clickDan('d');
	});
	function _getAbcd(){
        var _tmpArr=[];
        if(1 == _duoAbcd['a']){
        	_tmpArr.push('a');
        }
        if(1 == _duoAbcd['b']){
        	_tmpArr.push('b');
        }
        if(1 == _duoAbcd['c']){
        	_tmpArr.push('c');
        }
        if(1 == _duoAbcd['d']){
        	_tmpArr.push('d');
        }
        return _tmpArr.join(',');
	}
	function _clickDuo(_type){
          if(1 == _duoAbcd[_type]){
        	  _duoAbcd[_type]='';
        	  $(".duo-"+_type+"1 .duo-c").attr("src","<?php echo $url; ?>/img/duo-no.png");
          }else{
        	  _duoAbcd[_type]=1;
        	  $(".duo-"+_type+"1 .duo-c").attr("src","<?php echo $url; ?>/img/duo-yes.png");
          }
          _uD3[_tiIndex]=_getAbcd();
          console.log(_uD3);
	}
	
	$(".duo-a1").click(function(){
		_clickDuo('a');
	});
	$(".duo-b1").click(function(){
		_clickDuo('b');
	});
	$(".duo-c1").click(function(){
		_clickDuo('c');
	});
	$(".duo-d1").click(function(){
		_clickDuo('d');
	});
	
	function chinanum(num){  
	    var china = new Array('零','一','二','三','四','五','六','七','八','九');  
	    var arr = new Array();
	    var num=num+'';
	    var english = num.split("")  
	    for(var i=0;i<english.length;i++){
	        arr[i] = china[english[i]];
	    }
	    if(2 == english.length){
	        if('一' == arr[0]){
	        	return ('十'+arr[1]);
	        }else{
	        	return (arr[0]+'十'+arr[1]);
	        }
	    }else{
	    	return arr.join("")  
	    }
	}

});
</script>
</body>
</html>